using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Weazel.Microblaze.Simulator.Components.Microblaze.Disassembler
{
  public partial class DisassemblerViewForm : Form
  {
    public static void Show(Instruction[] instructions)
    {
      DisassemblerViewForm form =
        new DisassemblerViewForm();

      form.dataGridView1.Font = new Font("Courier New", 8.0f, FontStyle.Regular);
      form.dataGridView1.DataSource = instructions;
      form.dataGridView1.ColumnAdded += new DataGridViewColumnEventHandler(dataGridView1_ColumnAdded);

       
    

      //for (int i = 0; i < instructions.Length; i++)
      //{
      //  form.dataGridView1.Rows.Add(i.ToString(), instructions[i].ToString());
      //}

      //Console.WriteLine("instructions: " + instructions.Length);

      //for (int i = 0; i < instructions.Length; i++)
      //{
      // form.listView_disassemble.Items.Add(instructions[i].ToString());
      // // Console.WriteLine(instructions[i]);
      //}

      form.Show();
    }

    static void dataGridView1_ColumnAdded(object sender, DataGridViewColumnEventArgs e)
    {
      if (e.Column.HeaderText == "HexAddress")
      {
        e.Column.HeaderText = "Address";
        e.Column.Width = 100;
      }
      else if (e.Column.HeaderText == "Mnemonic") 
      {
        e.Column.HeaderText = "";
        e.Column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
        //e.Column.Width = e.Column.DataGridView.Width - 100;
      }
    }

    public DisassemblerViewForm()
    {
      InitializeComponent();
    }
  }
}